import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },

  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true
  },
  {
    path: "/",
    component: Layout,
    redirect: "/appUser"
    // children: [{
    //   path: 'home',
    //   name: '首页',
    //   component: () => import('@/views/home/index'),
    //   meta: { title: '首页', icon: 'icon-baseline-home-px' }
    // }]
  },
  {
    path: "/appUser",
    component: Layout,
    redirect: "/appUser/index",
    name: "首页",
    meta: { title: "手机用户", icon: "icon-dashujukeshihuaico-" },
    children: [
      {
        path: "index",
        name: "用户管理",
        component: () => import("@/views/appUser/index"),
        meta: { title: "用户管理", icon: "icon-user-list" }
      },
      {
        path: "appointmentSweepGrave",
        name: "用户预约扫墓",
        component: () => import("@/views/appUser/appointmentSweepGrave"),
        meta: { title: "用户预约扫墓", icon: "icon-yuyuejilu" }
      },
      {
        path: "sacrificeOnBehalfOf",
        name: "用户代为祭扫",
        component: () => import("@/views/appUser/sacrificeOnBehalfOf"),
        meta: { title: "用户代为祭扫", icon: "icon-yuyuejilu1" }
      },
      {
        path: "memorialHallList",
        name: "纪念馆列表",
        component: () => import("@/views/appUser/memorialHallList"),
        meta: { title: "纪念馆列表", icon: "icon-huizhanzhongxin" }
      },
      // {
      //   path: 'videoPictureList',
      //   name: '视频图片列表',
      //   component: () => import('@/views/appUser/videoPictureList'),
      //   meta: { title: '视频图片列表', icon: 'icon-shuffling-banner-fill' }
      // },
      {
        path: "eulogyMessage",
        name: "悼文留言管理",
        component: () => import("@/views/appUser/eulogyMessage"),
        meta: { title: "悼文留言管理", icon: "icon-01_wenzhangguanli" }
      }
    ]
  },
  {
    path: "/memorialHallConfig",
    component: Layout,
    redirect: "/memorialHallConfig/rulesConfig",
    name: "纪念馆配置",
    meta: { title: "纪念馆配置", icon: "icon-shezhi" },
    children: [
      // {
      //   path: 'rulesConfig',
      //   name: '规则配置',
      //   component: () => import('@/views/memorialHallConfig/rulesConfig'),
      //   meta: { title: '规则配置', icon: 'icon-jifenguizeguankong' }
      // },
      // {
      //   path: 'posterConfig',
      //   name: '海报配置',
      //   component: () => import('@/views/memorialHallConfig/posterConfig'),
      //   meta: { title: '海报配置', icon: 'icon-yingxiaogongju-cuxiaohaibao' }
      // },
      {
        path: "rulesConfig",
        name: "海报配置",
        component: () => import("@/views/memorialHallConfig/rulesConfig"),
        meta: {
          title: "海报配置",
          icon: "icon-yingxiaogongju-cuxiaohaibao"
        }
      }
    ]
  },
  {
    path: "/adminConfig",
    component: Layout,
    redirect: "/adminConfig/index",
    name: "后台配置",
    meta: { title: "后台配置", icon: "icon-shezhi1" },
    children: [
      {
        path: "index",
        name: "全局配置",
        component: () => import("@/views/adminConfig/index"),
        meta: { title: "全局配置", icon: "icon-zixuantaocan" }
      },
      // {
      //   path: "taskConfig",
      //   name: "任务配置",
      //   component: () => import("@/views/adminConfig/taskConfig"),
      //   meta: { title: "任务配置", icon: "icon-hetongguizeguankong" }
      // },
      {
        path: "goodsConfig",
        name: "商品管理",
        component: () => import("@/views/adminConfig/goodsConfig"),
        meta: { title: "商品管理", icon: "icon-shangpin3" }
      },
      {
        path: "goodsTypeConfig",
        name: "商品类型管理",
        component: () => import("@/views/adminConfig/goodsTypeConfig"),
        meta: { title: "商品类型管理", icon: "icon-shangpin3" }
      },
      {
        path: "bannerConfig",
        name: "Banner配置",
        component: () => import("@/views/adminConfig/bannerConfig"),
        meta: { title: "Banner配置", icon: "icon-banner" }
      },
      {
        path: "rechargePackageConfig",
        name: "充值套餐配置",
        component: () => import("@/views/adminConfig/rechargePackageConfig"),
        meta: { title: "充值套餐配置", icon: "icon-chongzhi" }
      },
      {
        path: "memorialBackground",
        name: "纪念馆背景图片/音乐",
        component: () => import("@/views/adminConfig/memorialBackground"),
        meta: { title: "纪念馆背景图片/音乐", icon: "icon-chongzhi" }
      },
      {
        path: "appointmentManageConfig",
        name: "预约管理配置",
        component: () => import("@/views/adminConfig/appointmentManageConfig"),
        meta: { title: "预约管理配置", icon: "icon-yuyuejilu" }
      }
    ]
  },
  // {
  //   path: '/cemeteryDeadManage',
  //   component: Layout,
  //   children: [{
  //     path: '/cemeteryDeadManage',
  //     component: () => import('@/views/cemeteryDeadManage/index'),
  //     name:'公墓逝者管理',
  //     meta: { title: '公墓逝者管理', icon: 'icon-yonghu' }
  //   }]
  // },
  // {
  //   path: '/orderManage',
  //   component: Layout,
  //   children: [{
  //     path: '/orderManage',
  //     component: () => import('@/views/orderManage/index'),
  //     name:'订单管理',
  //     meta: { title: '订单管理', icon: 'icon-liebiao2' }
  //   }]
  // },
  {
    path: "/adminUser",
    component: Layout,
    children: [
      {
        path: "/adminUser",
        component: () => import("@/views/adminUser/index"),
        name: "后台用户管理",
        meta: { title: "后台用户管理", icon: "icon-24gf-newspaper2" }
      }
    ]
  },
  {
    path: "/industryNewsManage",
    component: Layout,
    children: [
      {
        path: "/industryNewsManage",
        component: () => import("@/views/industryNewsManage/index"),
        name: "行业动态管理",
        meta: { title: "行业动态管理", icon: "icon-24gf-newspaper2" }
      }
    ]
  },
  // {
  //   path: '/myFamily',
  //   component: Layout,
  //   children: [{
  //     path: '/myFamily',
  //     component: () => import('@/views/myFamily/index'),
  //     name:'我的家属',
  //     meta: { title: '我的家属', icon: 'icon-family' }
  //   }]
  // },
  {
    path: "/messageManage",
    component: Layout,
    children: [
      {
        path: "/messageManage",
        component: () => import("@/views/messageManage/index"),
        name: "消息管理",
        meta: { title: "消息管理", icon: "icon-fill-news" }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true }
];

const createRouter = () =>
  new Router({
    mode: "history", // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
